from mcp.http import HttpService, Response

# 创建 HTTP 服务
service = HttpService()

# 定义根路由
@service.route("/", methods=["GET"])
async def home(request):
    return Response.json({"message": "Hello MCP HTTP!"})

# 带参数的路由
@service.route("/greet/{name}", methods=["GET"])
async def greet(request, name: str):
    return Response.text(f"Hello, {name}!")

# 启动服务 (端口 8080)
if __name__ == "__main__":
    service.run(port=8080)